<?php
/**
 * Create by PhpStorm
 * User: lcz
 * DATE: 2019/8/27
 * Time: 9:23
 * 自定义日志
 */

namespace app\common\library\log;

use app\common\library\Sms;

class Log {
	public static function info($data, $path = 'infoLog') {
		self::write($path, $data);
	}
	
	public static function err($data, $path = 'errorLog') {
		self::write($path, $data);
//		$res = Sms::notice('632867905@qq.com', '要培训代码出现bug，请及时处理');
	}
	
	private static function write($path, $data) {
		$dir = RUNTIME_PATH.$path;
		if (!is_dir($dir)) {
			mkdir($dir, 0755, true);
		}
		
		$fileName = $dir. DS . date('Y-m-d') . '.txt';
		file_put_contents($fileName, var_export($data, true), FILE_APPEND);
	}
}